<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="main"/>
  <calendar:resources lang="en" theme="aqua"/>
  <title>${message(code: 'customer.nav.edit')}</title>
</head>
<body>
<div class="nav">
  <span class="menuButton"><g:link class="list" action="list">${message(code: 'customer.nav.list')}</g:link></span>
  <span class="menuButton"><g:link class="create" action="create">${message(code: 'customer.nav.create')}</g:link></span>
</div>
<div class="body">
  <h1>${message(code: 'customer.nav.edit')}</h1>
  <g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
  </g:if>
  <g:hasErrors bean="${customerInstance}">
    <div class="errors">
      <g:renderErrors bean="${customerInstance}" as="list"/>
    </div>
  </g:hasErrors>
  <g:form method="post">
    <input type="hidden" name="id" value="${customerInstance?.id}"/>
    <div class="dialog">
      <table>
        <tbody>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="name">${message(code: 'customer.table.name')}<ps:mandatory/>:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: customerInstance, field: 'name', 'errors')}">
            <input type="text" id="name" name="name" value="${fieldValue(bean: customerInstance, field: 'name')}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="dob">${message(code: 'customer.table.dob')}:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: customerInstance, field: 'dob', 'errors')}">
            <calendar:datePicker name="dob" value="${customerInstance?.dob}" dateFormat="%Y/%m/%d" years="1900, 2049"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="handPhone">${message(code: 'customer.table.phone')}<ps:mandatory/>:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: customerInstance, field: 'handPhone', 'errors')}">
            <input type="text" id="handPhone" name="handPhone" value="${fieldValue(bean: customerInstance, field: 'handPhone')}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="cardNumber">${message(code: 'customer.table.cardNumber')}:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: customerInstance, field: 'cardNumber', 'errors')}">
            <input type="text" id="cardNumber" name="cardNumber" value="${fieldValue(bean: customerInstance, field: 'cardNumber')}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="street">${message(code: 'customer.table.street')}:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: customerInstance, field: 'street', 'errors')}">
            <input type="text" id="street" name="street" value="${fieldValue(bean: customerInstance, field: 'street')}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="postalCode">${message(code: 'customer.table.postal')}:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: customerInstance, field: 'postalCode', 'errors')}">
            <input type="text" id="postalCode" name="postalCode" value="${fieldValue(bean: customerInstance, field: 'postalCode')}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="homePhone">${message(code: 'customer.table.home.phone')}:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: customerInstance, field: 'homePhone', 'errors')}">
            <input type="text" id="homePhone" name="homePhone" value="${fieldValue(bean: customerInstance, field: 'homePhone')}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="jobs">${message(code: 'customer.table.job')}:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: customerInstance, field: 'jobs', 'errors')}">

            <ul>
              <g:each var="j" in="${customerInstance?.jobs?}">
                <li><g:link controller="job" action="show" id="${j.id}">${j?.encodeAsHTML()}</g:link></li>
              </g:each>
            </ul>
            <g:link controller="job" params="['customer.id':customerInstance?.id]" action="create"><g:message code="customer.button.addjob"/></g:link>

          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="membership">${message(code: 'customer.table.membership')}:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: customerInstance, field: 'membership', 'errors')}">
            <g:select optionKey="id" from="${Membership.list()}" name="membership.id" value="${customerInstance?.membership?.id}"></g:select>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="point">${message(code: 'customer.table.point')}:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: customerInstance, field: 'point', 'errors')}">
            <input type="text" id="point" name="point" value="${fieldValue(bean: customerInstance, field: 'point')}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="remark">${message(code: 'customer.table.remark')}:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: customerInstance, field: 'remark', 'errors')}">
            <input type="text" id="remark" name="remark" value="${fieldValue(bean: customerInstance, field: 'remark')}"/>
          </td>
        </tr>

        </tbody>
      </table>
    </div>
    <div class="buttons">
      <span class="button"><g:actionSubmit class="save" action="update" value="${message(code:'customer.nav.edit')}"/></span>
      <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete"/></span>
    </div>
  </g:form>
</div>
</body>
</html>
